package com.lizardmind.haofudoctor.other.rongYun

import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import com.linxiao.framework.util.ke
import com.linxiao.framework.util.toasts
import com.lizardmind.haofudoctor.R
import com.lizardmind.haofudoctor.other.DoctorInfo.id
import com.lizardmind.haofudoctor.other.KaiFangFinishEvent
import com.lizardmind.haofudoctor.other.jsonOf
import com.lizardmind.haofudoctor.ui.diagnosis.diagnose.SendDiagnoseActivity
import com.lizardmind.haofudoctor.ui.diagnosis.sickMan.advisory.BianZhengKaiFangActivity
import com.lizardmind.haofudoctor.ui.diagnosis.visit.SendVisitActivity
import com.lizardmind.haofudoctor.ui.studio.sickEducation.SickEducationActivity
import io.rong.imkit.RongExtension
import io.rong.imkit.RongIM
import io.rong.imkit.fragment.ConversationFragment
import io.rong.imkit.plugin.IPluginModule
import io.rong.imlib.RongIMClient
import io.rong.imlib.model.Conversation
import io.rong.imlib.model.Message
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.intentFor
import org.json.JSONObject

/**
 * 问诊单 plugin
 * Created by Extends on 2017/12/4 11:55
 */
class DiagnosePlugin :IPluginModule {
    override fun onClick(p0: Fragment, p1: RongExtension)
        = p1.startActivityForPluginResult(p0.activity.intentFor<SendDiagnoseActivity>("user_id" to (p0 as ConversationFragment).targetId.substring(1)),50,this)

    override fun obtainDrawable(p0: Context): Drawable = ContextCompat.getDrawable(p0, R.drawable.rc_ext_plugin_diagnose_selector)

    override fun obtainTitle(p0: Context?): String ="问诊单"

    override fun onActivityResult(p0: Int, p1: Int, p2: Intent?) {}
}

/**
 * 方案 plugin
 * Created by Extends on 2017/12/4 11:55
 */
class FanganPlugin :IPluginModule {
    override fun onClick(p0: Fragment, p1: RongExtension)
            = p1.startActivityForPluginResult(p0.activity.intentFor<BianZhengKaiFangActivity>("user_id" to (p0 as ConversationFragment).targetId.substring(1)),51,this)
    override fun obtainDrawable(p0: Context): Drawable = ContextCompat.getDrawable(p0, R.drawable.rc_ext_plugin_fangan_selector)

    override fun obtainTitle(p0: Context?): String ="方案"

    override fun onActivityResult(p0: Int, p1: Int, p2: Intent?) {}
}

/**
 * 随访复诊单 plugin
 * Created by Extends on 2017/12/4 11:55
 */
class VisitPlugin :IPluginModule {
    override fun onClick(p0: Fragment, p1: RongExtension)
            = p1.startActivityForPluginResult(p0.activity.intentFor<SendVisitActivity>("uid" to (p0 as ConversationFragment).targetId.substring(1)),52,this)

    override fun obtainDrawable(p0: Context): Drawable = ContextCompat.getDrawable(p0, R.drawable.rc_ext_plugin_visit_selector)

    override fun obtainTitle(p0: Context?): String ="随访复诊单"

    override fun onActivityResult(p0: Int, p1: Int, p2: Intent?) {}
}


/**
 * 患教 plugin
 * Created by Extends on 2017/12/4 11:55
 */
class PatientsEducationPlugin :IPluginModule {
    override fun onClick(p0: Fragment, p1: RongExtension)
            = p1.startActivityForPluginResult(p0.activity.intentFor<SickEducationActivity>("uid" to (p0 as ConversationFragment).targetId.substring(1)),53,this)

    override fun obtainDrawable(p0: Context): Drawable = ContextCompat.getDrawable(p0, R.drawable.rc_ext_plugin_edu_selector)

    override fun obtainTitle(p0: Context?): String ="患教"

    override fun onActivityResult(p0: Int, p1: Int, p2: Intent?) {}
}